<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>二手交易平台</title>
  <link rel="stylesheet" type="text/css" href="/ssm/consumer/res/static/css/main.css">
  <link rel="stylesheet" type="text/css" href="/ssm/consumer/res/layui/css/layui.css">
  <script type="text/javascript" src="/ssm/consumer/res/layui/layui.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
</head>
<body>

  <div class="header">
    <div class="headerLayout w1200">
      <div class="headerCon">
        <h1 class="mallLogo">
          <a href="/ssm/consumer/index.html" title="二手交易平台">
            <img src="/ssm/consumer/res/static/img/logo.png">
          </a>
        </h1>
      </div>
    </div>
  </div>


  <div class="content content-nav-base  login-content">
    <div class="main-nav">
      <div class="inner-cont0">
        <div class="inner-cont1 w1200">
          <div class="inner-cont2">
            <a href="#" class="active">登录</a>
          </div>
        </div>
      </div>
    </div>
    <div class="login-bg">
      <div class="login-cont w1200">
        <div class="form-box">
          <form class="layui-form" action="">
            <legend>会员登录</legend>
            <div class="layui-form-item">
              <div class="layui-inline iphone">
                <div class="layui-input-inline">
                  <i class="layui-icon layui-icon-cellphone iphone-icon"></i>
                  <input type="tel" name="phone" id="username" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline veri-code">
                <div class="layui-input-inline">
                 <i class="layui-icon layui-icon-password iphone-icon"></i>
                  <input style="padding-left: 40px;" id="password" type="password" name="pnum" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
                <div>
                	<a href="/ssm/consumer/zhaohui.html">找回密码</a>
                </div>
              </div>
            </div>
            <div class="layui-form-item login-btn">
              <div class="layui-input-block" style="padding-top: 10px;">
                <button class="layui-btn" lay-submit="" lay-filter="demo1" onclick="return false">登录</button>
              </div>
              <div class="layui-input-block" style="padding-top: 10px;">
                <button class="layui-btn" id="toRegister" lay-filter="demo2" onclick="return false">注册</button>
              </div>
              
            </div>
            
          </form>
        </div>
      </div>
    </div>
  </div>

  
  <script type="text/javascript">
   layui.config({
      base: '/ssm/consumer/res/static/js/util' //你存放新模块的目录，注意，不是layui的模块目录
    }).use(['jquery','form'],function(){
          var $ = layui.$,form = layui.form;


        $("#find").click(function() {
            if(!/^1\d{10}$/.test($("#phone").val())){
              layer.msg("请输入正确的手机号");
              return false;
            }
            var obj=this;
            $.ajax({
                type:"get",
                url:"../json/login.json",
                dataType:"json",//返回的
                success:function(data) {
                    
                    if(data.result){
                        $("#find").addClass(" layui-btn-disabled");
                        $('#find').attr('disabled',"true");
                        settime(obj);
                        $("#msg").text(data.msg);
                    }else{
                        layer.msg(data.msg);
                    }
                },
                error:function(msg) {
                    console.log(msg);
                }
            }); 
        })
        var countdown=60; 
        function settime(obj) { 
        if (countdown == 0) { 
            obj.removeAttribute("disabled"); 
            obj.classList.remove("layui-btn-disabled")
            obj.value="获取验证码"; 
            countdown = 60; 
            return;
        } else { 
            
            obj.value="重新发送(" + countdown + ")"; 
            countdown--; 
        } 
        setTimeout(function() { 
            settime(obj) }
            ,1000) 
        }
        
        
        layui.form.on('submit(demo1)', function(data){
        	var username = $("#username").val();
 		   var password = $("#password").val();
 		   if(username&&password){
 			   var qUrl="/ssm/consumer/login.do";
 	           $.post(qUrl,{
 	           	"username":username,
 					"password":password
 	           },function(res){
 	            if(res.code=="01"){
 	                location.href="/ssm/consumer/index.html";
 	            }else{
 	                layer.msg("账号或密码错误");
 	            }
 	           })
 		   }else{
 			   layer.msg("请填写完整");
 		   }
 		   return false;
    	});
        $("#toRegister").click(function(){
        	location.href="/ssm/consumer/register.html";
        })
        
        $("#searchbutton").click(function Search(){
        	location.href="/ssm/consumer/index.html?pname="+$("#keyword").val();
        	return false;
        })

    })
    
    
	
  </script>

</body>
</html>